package cn.wolfcode.crm.service.imp;


import cn.wolfcode.crm.domain.AccountBook;
import cn.wolfcode.crm.mapper.AccountBookMapper;
import cn.wolfcode.crm.qo.PageResult;
import cn.wolfcode.crm.qo.QueryObject;
import cn.wolfcode.crm.service.IAccountBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AccountBookServiceImpl implements IAccountBookService {
    @Autowired
    private AccountBookMapper accountBookMapper;


    @Override

    public void save(AccountBook record) {
        if (record != null) {

            accountBookMapper.insert(record);
        }

    }

    @Override
    public AccountBook selectByPrimaryKey(Long id) {

            AccountBook dept = accountBookMapper.selectByPrimaryKey(id);
        return dept;

    }

    @Override
    public List<AccountBook> selectAll() {
        List<AccountBook> depts = accountBookMapper.selectAll();
        return depts;
    }






    @Override
    public PageResult queryForList(QueryObject qo) {
        int rows = accountBookMapper.rows(qo);
        if (rows==0) {
            return PageResult.EMPTY_RESULT;
        }
        PageResult result =  new PageResult(rows,accountBookMapper.queryForList(qo));
        return result;
    }


}
